package com.rhok.wthru_client.servermsgs;

import org.apache.http.message.BasicNameValuePair;

import com.rhok.wthru_client.BasicContactInfo;
import com.rhok.wthru_client.GlobalConfiguration;

import android.content.Context;

public abstract class ServerMessageWithSelfInfo extends ServerMessage {

	protected BasicContactInfo m_selfInfo = null;
	protected String m_uid = "";
	
	public void setUid(String uid) {
		m_uid = uid;
	}

	public ServerMessageWithSelfInfo(Context context) {
		super(context);

		readInfo();
	}
	
	private void readInfo() {
		
		GlobalConfiguration globalConf = GlobalConfiguration.getInstance(m_context);
		
		String uid = globalConf.getString(GlobalConfiguration.CONF_KEY_UNIQUE_ID);
		String name = globalConf.getString(GlobalConfiguration.CONF_KEY_NAME);
		String phone = globalConf.getString(GlobalConfiguration.CONF_KEY_PHONE);
		
		m_uid = uid;
		m_selfInfo = new BasicContactInfo(name, phone);
	}
	
	protected void addStandardRequestHeaders() {
		m_requestValues.add(new BasicNameValuePair("self", m_selfInfo.toString()));
		m_requestValues.add(new BasicNameValuePair("uid", m_uid));
		super.addStandardRequestHeaders();
	}

}
